#ifndef __LCD1602_H__
#define __LCD1602_H__

#include <REGX52.H>
#include <stdint.h>

#define LCD1602_Port P0

sbit LCD1602_RS = P2^6;
sbit LCD1602_RW = P2^5;
sbit LCD1602_EN = P2^7;

void LCD1602_Data(uint8_t d);
void LCD1602_Init(void);
void LCD1602_CreateChar(uint8_t addr, uint8_t code *graph);
void LCD1602_PutStr_c(char code *str);
void LCD1602_PutStr(char *str);
void LCD1602_PrintAll(char code *str1, char code *str2);

#define LCD1602_DataMode() (LCD1602_RS = 1)
#define LCD1602_CMDMode() (LCD1602_RS = 0)
#define LCD1602_ReadMode() (LCD1602_RW = 1)
#define LCD1602_WriteMode() (LCD1602_RW = 0)

#define LCD1602_Reset() (LCD1602_CMDMode(), LCD1602_Data(0x01))
#define LCD1602_DDRamAddr(addr) (LCD1602_CMDMode(), LCD1602_Data(0x80 | (addr)))

#endif